import 'package:flutter/material.dart';
import 'package:flutter_oldman_health/pages/family_member_list_page.dart';
import 'package:flutter_oldman_health/pages/user_pager.dart';

class TabNavigation extends StatefulWidget {
  @override
  _TabNavigation createState() => _TabNavigation();
}

class _TabNavigation extends State<TabNavigation> {
  final PageController _controller = PageController(initialPage: 0);
  final _defaultColor = Color(0xFFEEEEEE);
  final _activeColor = Color(0xFF0D47A1);
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        controller: _controller,
        children: [ FamilyMemberListPage(), UserPager()],//HomePage(),
        onPageChanged: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.black,
        currentIndex: _currentIndex,
        onTap: (index) {
          _controller.jumpToPage(index);
        },
        fixedColor: _activeColor,
        unselectedItemColor: _defaultColor,
        type: BottomNavigationBarType.fixed,
        items: [
          // BottomNavigationBarItem(
          //     icon: ImageIcon(
          //       AssetImage("images/home.png"),
          //       // Icons.home_outlined,
          //       color: _defaultColor,
          //     ),
          //     activeIcon: ImageIcon(
          //       AssetImage("images/home.png"),
          //       // Icons.home_outlined,
          //       color: _activeColor,
          //     ),
          //     title: Text("首页",
          //         style: TextStyle(
          //             fontSize: 18,
          //             color:
          //                 _currentIndex == 0 ? _activeColor : _defaultColor))),
          BottomNavigationBarItem(
              icon: ImageIcon(
                AssetImage("images/member.png"),
                // Icons.home_outlined,
                color: _defaultColor,
              ),
              activeIcon: ImageIcon(
                AssetImage("images/member.png"),
                // Icons.home_outlined,
                color: _activeColor,
              ),
              title: Text("家庭成员",
                  style: TextStyle(
                      fontSize: 18,
                      color:
                          _currentIndex == 0 ? _activeColor : _defaultColor))),
          BottomNavigationBarItem(
              icon: ImageIcon(
                AssetImage("images/personal.png"),
                // Icons.home_outlined,
                color: _defaultColor,
              ),
              activeIcon: ImageIcon(
                AssetImage("images/personal.png"),
                // Icons.home_outlined,
                color: _activeColor,
              ),
              title: Text("个人中心",
                  style: TextStyle(
                      fontSize: 18,
                      color:
                          _currentIndex == 1 ? _activeColor : _defaultColor))),
        ],
      ),
    );
  }
}
